<!DOCTYPE html>
<html lang="en-US">
    <head>
        <title>HTML::StripScripts - Strip scripting constructs out of HTML - metacpan.org</title>
        <link rel="preload" as="fetch" href="https://metacpan.org/account/login_status" crossorigin="anonymous" />
        <link href="https://metacpan.org/_assets/b8ccceeed47a0652049703d99326a9cea4933443.css" rel="stylesheet" type="text/css">
        <script src="https://metacpan.org/_assets/6bfedafe2d7caa915b7d84f61b45936818e3242e.js" type="text/javascript" defer></script>
        <link rel="alternate" type="application/rss+xml" title="Recent CPAN Uploads of HTML-StripScripts - MetaCPAN" href="https://metacpan.org/dist/HTML-StripScripts/releases.rss" />
        <link rel="canonical" href="./HTML::StripScripts.html" />
        <meta name="description" content="Strip scripting constructs out of HTML" />
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5">
        <link rel="shortcut icon" href="https://metacpan.org/static/icons/favicon.ico">
        <link rel="apple-touch-icon" sizes="152x152" href="https://metacpan.org/static/icons/apple-touch-icon.png">
        <link rel="search" href="https://metacpan.org/static/opensearch.xml" type="application/opensearchdescription+xml" title="MetaCPAN">
        <script>
          (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
          (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
          })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

          (function(skey, ga_id){
            ga('create', ga_id, {
              siteSpeedSampleRate : 100,
              storage             : 'none',
              clientId            : localStorage.getItem(skey)
            });
            ga(function(tracker) {
              localStorage.setItem(skey, tracker.get('clientId'));
            });
            ga('send', 'pageview');
          })('ga:clientId', 'UA-27829474-1');
        </script>
<meta name="twitter:card"        content="summary" />
<meta name="twitter:url"         content="https://metacpan.org/pod/HTML::StripScripts" />
<meta name="twitter:title"       content="HTML::StripScripts" />
<meta name="twitter:description" content="Strip scripting constructs out of HTML" />
<meta name="twitter:site"        content="metacpan" />
    </head>
    <body>
        <nav class="navbar navbar-default" role="navigation">
            <div class="header-logo-large hidden-xs">
              <a href="https://metacpan.org/" tabindex="0">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#logo" />
                </svg>
              </a>
            </div>
            <div class="header-logo-icon visible-xs">
              <a href="https://metacpan.org/">
                <svg class="logo" aria-label="MetaCPAN">
                  <use class="logo" href="/static/images/metacpan-logo.svg#dots" />
                </svg>
              </a>
            </div>
            <ul class="nav navbar-nav menu-items hidden-xs hidden-sm">
              <li><a href="https://metacpan.org/about">About</a></li>
              <li><a href="https://metacpan.org/about/sponsors">Sponsor</a></li>
              <li><a href="https://grep.metacpan.org/">grep::cpan</a></li>
              <li><a href="https://metacpan.org/recent">Recent</a></li>
              <li><a href="https://metacpan.org/about/faq">FAQ</a></li>
              <li><a href="https://metacpan.org/tools">Tools</a></li>
              <li><a href="https://fastapi.metacpan.org/">API</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <button type="button" class="searchbar-btn visible-xs visible-sm">
                    <i class="fa fa-search button-fa-icon"></i>
                </button>
                <form action="https://metacpan.org/search" class="searchbar-form visible-md visible-lg search-form form-horizontal">
                   <input type="hidden" name="size" id="metacpan_search-size" value="20">
                  <div class="form-group">
                      <div class="search-group">
                        <i class="fa fa-search"></i>
                        <input type="text" name="q" placeholder="Search the CPAN" size="41" autocorrect="off" autocapitalize="off" spellcheck="false" id="metacpan_search-input" class="form-control" value="">
                      </div>
                  </div>
                </form>
                    <li class="icon-slidepanel visible-xs visible-sm">
                      <button data-toggle="slidepanel" data-target=".slidepanel">
                        <span class="button-fa-icon">
                          <i class="fa fa-bars slidepanel-open"></i>
                          <i class="fa fa-times slidepanel-close"></i>
                        </span>
                      </button>
                    </li>
                <form action="https://metacpan.org/account/logout" method="POST" id="metacpan-logout"></form>
                <li class="dropdown logged_in" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon logged-in-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li><a href="https://metacpan.org/account/identities">Identities</a></li>
                        <li><a href="https://metacpan.org/account/profile">Profile</a></li>
                        <li><a href="https://metacpan.org/account/favorite/list">Favorites</a></li>
                        <li>
                            <a href="./HTML::StripScripts.html#" type="button" onclick="$('#metacpan-logout').submit(); return false">
                              Logout
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_out" style="display: none;">
                    <button type="button" class="dropdown-toggle" data-toggle="dropdown">
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                      <i class="fas fa-chevron-down"></i>
                    </button>
                    <ul class="dropdown-menu">
                        <li>
                            <a href="https://metacpan.org/login/github">
                                <i class="fab fa-github fa-fw"></i>
                                GitHub
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/twitter">
                                <i class="fab fa-twitter fa-fw"></i>
                                Twitter
                            </a>
                        </li>
                        <li>
                            <a href="https://metacpan.org/login/google">
                                <i class="fab fa-google fa-fw"></i>
                                Google
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="dropdown logged_placeholder">
                    <button>
                      <i class="fa fa-user button-fa-icon" aria-hidden="true"></i>
                    </button>
                </li>
            </ul>
        </nav>
        <div class="page-content ">
          <!--
          <div class="top-notify-banner">
            <i class="fas fa-info-circle"></i>
          </div>
          -->
          <nav class="sidebar">
            <div class="slidepanel">
              <ul class="nav-list ">
    <li class="nav-header no-margin-top">
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The date that this version of HTML-StripScripts was released.">
      <span class="relatize">12 May 2016 09:44:35 UTC</span>
    </li>
  <li>
    Distribution: <a href="https://metacpan.org/dist/HTML-StripScripts">HTML-StripScripts</a>
  </li>
  <li>
    Module version: 1.06
  </li>
  <li>
    <a data-keyboard-shortcut="g s" href="https://metacpan.org/dist/HTML-StripScripts/source/lib/HTML/StripScripts.pm">Source</a>
    (<a href="https://metacpan.org/dist/HTML-StripScripts/source/lib/HTML/StripScripts.pm?raw=1">raw</a>)
  </li>
  <li>
    <a data-keyboard-shortcut="g b" href="https://metacpan.org/dist/HTML-StripScripts/source/lib/HTML">Browse</a>
    (<a href="https://metacpan.org/dist/HTML-StripScripts/source/lib/HTML?raw=1">raw</a>)
  </li>
    <li>
      <a data-keyboard-shortcut="g c" href="https://metacpan.org/dist/HTML-StripScripts/changes">Changes</a>
    </li>
    <li>
      <a class="nopopup" href="https://metacpan.org/dist/HTML-StripScripts/contribute">How to Contribute</a>
    </li>
    <li>
        <a rel="noopener nofollow" data-keyboard-shortcut="g r" href="https://github.com/clintongormley/perl-html-stripscripts">Repository</a>
    </li>
    <li>
      <a rel="noopener nofollow" data-keyboard-shortcut="g i" href="https://github.com/clintongormley/perl-html-stripscripts/issues">Issues</a>
      (3)
    </li>
    <li>
      <a rel="noopener nofollow" href="http://matrix.cpantesters.org/?dist=HTML-StripScripts+1.06" title="Matrix">Testers</a>
        <span title="(pass / fail / na)">(<a rel="noopener nofollow" href="https://www.cpantesters.org/distro/H/HTML-StripScripts.html?oncpan=1&amp;distmat=1&amp;version=1.06&amp;grade=2" style="color: #090">27</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/H/HTML-StripScripts.html?oncpan=1&amp;distmat=1&amp;version=1.06&amp;grade=3" style="color: #900">0</a> / <a rel="noopener nofollow" href="https://www.cpantesters.org/distro/H/HTML-StripScripts.html?oncpan=1&amp;distmat=1&amp;version=1.06&amp;grade=4">0</a>)</span>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpants.cpanauthors.org/release/DRTECH/HTML-StripScripts-1.06">Kwalitee</a>
    </li>
    <li>
      <div class="ttip" data-toggle="tooltip" data-placement="bottom" title="The # people with an indexing permission on HTML-StripScripts who have released something to CPAN in the last 2 years (i.e. the # people likely able to release critical fixes in a timely manner)">
      Bus factor: 0
      </div>
    </li>
    <li>
      <a rel="noopener nofollow" href="http://cpancover.com/latest/HTML-StripScripts-1.06/index.html">91.37% Coverage </a>
    </li>
    <li>
      License: perl_5
    </li>
    <li class="nav-header">Activity</li>
    <li>
<div class="activity-graph">
    <img src="https://metacpan.org/dist/HTML-StripScripts/activity.svg?res=month" />
    <div class="comment">24 month</div>
</div>
    </li>
    <li class="nav-header">Tools</li>
    <li>
      <a itemprop="downloadUrl" href="https://cpan.metacpan.org/authors/id/D/DR/DRTECH/HTML-StripScripts-1.06.tar.gz">
      Download (<span itemprop="fileSize">43.7KB</span>)</a>
    </li>
    <li>
      <a href="https://explorer.metacpan.org/?url=%2Fmodule%2FDRTECH%2FHTML-StripScripts-1.06%2Flib%2FHTML%2FStripScripts.pm">
        MetaCPAN Explorer
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/HTML-StripScripts/permissions">
        Permissions
      </a>
    </li>
    <li>
      <a href="https://metacpan.org/dist/HTML-StripScripts/releases.rss">
        Subscribe to distribution
      </a>
    </li>
    <li>
      <button class="btn btn-link" data-toggle="modal" data-target="#metacpan_install-instructions-dialog">
        Install Instructions
      </button>
    </li>
    <li>
      <form action="https://metacpan.org/search">
        <input type="hidden" name="q" value="dist:HTML-StripScripts">
        <input type="search" name="q" placeholder="Search distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
      </form>
    </li>
    <li>
      <form action="https://grep.metacpan.org/search">
        <input type="hidden" name="qd" value="HTML-StripScripts">
        <input type="hidden" name="source" value="metacpan">
        <input type="search" name="q" placeholder="grep distribution" class="form-control tool-bar-form">
        <input type="submit" style="display: none">
     </form>
    </li>
    <li class="version-jump">
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/HTML/StripScripts.pm&#39;" class="form-control tool-bar-form">
  <option disabled selected>Jump to version</option>
<option
  disabled
  value="DRTECH/HTML-StripScripts-1.06"
>1.06
  (DRTECH on 2016-05-12)</option>
<optgroup label="BackPAN">'
<option
  
  value="DRTECH/HTML-StripScripts-1.05"
>1.05
  (DRTECH on 2009-11-05)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.04"
>1.04
  (DRTECH on 2007-11-16)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.03"
>1.03
  (DRTECH on 2007-10-22)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.02"
>1.02
  (DRTECH on 2007-10-22)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.01"
>1.01
  (DRTECH on 2007-10-22)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.00"
>1.00
  (DRTECH on 2007-06-05)</option>
<option
  
  value="DRTECH/HTML-StripScripts-0.991"
>0.991
  (DRTECH on 2007-05-29)</option>
<option
  
  value="DRTECH/HTML-StripScripts-0.99"
>0.99
  (DRTECH on 2007-05-28)</option>
<option
  
  value="DRTECH/HTML-StripScripts-0.90"
>0.90
  (DRTECH on 2007-05-28)</option>
<option
  
  value="NCLEATON/HTML-StripScripts-0.03"
>0.03
  (NCLEATON on 2004-04-27)</option>
<option
  
  value="NCLEATON/HTML-StripScripts-0.02"
>0.02
  (NCLEATON on 2003-07-25)</option>
<option
  
  value="NCLEATON/HTML-StripScripts-0.01"
>0.01
  (NCLEATON on 2003-03-30)</option>
</optgroup>
</select>
    </li>
    <li class="version-diff">
<select onchange="document.location.href='/release/DRTECH/HTML-StripScripts-1.06/diff/' + encodeURIComponent(this.value) + '/lib/HTML/StripScripts.pm'
" class="form-control tool-bar-form">
  <option disabled selected>Diff with version</option>
<option
  disabled
  value="DRTECH/HTML-StripScripts-1.06"
>1.06
  (DRTECH on 2016-05-12)</option>
<optgroup label="BackPAN">'
<option
  
  value="DRTECH/HTML-StripScripts-1.05"
>1.05
  (DRTECH on 2009-11-05)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.04"
>1.04
  (DRTECH on 2007-11-16)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.03"
>1.03
  (DRTECH on 2007-10-22)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.02"
>1.02
  (DRTECH on 2007-10-22)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.01"
>1.01
  (DRTECH on 2007-10-22)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.00"
>1.00
  (DRTECH on 2007-06-05)</option>
<option
  
  value="DRTECH/HTML-StripScripts-0.991"
>0.991
  (DRTECH on 2007-05-29)</option>
<option
  
  value="DRTECH/HTML-StripScripts-0.99"
>0.99
  (DRTECH on 2007-05-28)</option>
<option
  
  value="DRTECH/HTML-StripScripts-0.90"
>0.90
  (DRTECH on 2007-05-28)</option>
<option
  
  value="NCLEATON/HTML-StripScripts-0.03"
>0.03
  (NCLEATON on 2004-04-27)</option>
<option
  
  value="NCLEATON/HTML-StripScripts-0.02"
>0.02
  (NCLEATON on 2003-07-25)</option>
<option
  
  value="NCLEATON/HTML-StripScripts-0.01"
>0.01
  (NCLEATON on 2003-03-30)</option>
</optgroup>
</select>
    </li>

    <li>
<ul class="dependencies">
  <li class="nav-header">Dependencies</li>
  <li><a href="https://metacpan.org/pod/strict" title="strict" class="ellipsis">strict</a></li>
  <li><a href="https://metacpan.org/pod/vars" title="vars" class="ellipsis">vars</a></li>
  <li><a href="https://metacpan.org/pod/warnings" title="warnings" class="ellipsis">warnings</a></li>
  <li>
    <hr>
  </li>
  <li>
    <a href="https://metacpan.org/module/HTML::StripScripts/requires">Reverse dependencies</a>
  </li>
  <li>
    <a href="http://deps.cpantesters.org/?module=HTML%3A%3AStripScripts">CPAN Testers List</a>
  </li>
  <li>
    <a href="https://cpandeps.grinnz.com/?dist=HTML-StripScripts">Dependency graph</a>
  </li>
</ul>
    </li>
    <li class="nav-header">Permalinks</li>
    <li>
      <a href="https://metacpan.org/release/DRTECH/HTML-StripScripts-1.06/view/lib/HTML/StripScripts.pm">This version</a>
    </li>
    <li>
      <a href="./HTML::StripScripts.html">Latest version</a>
    </li>
    <li>
    </li>
    <li>
    </li>
              </ul>
            </div>
          </nav>
          <div class="content-navigation">
<div class="breadcrumbs">
  <span>
    <a data-keyboard-shortcut="g a" rel="author" href="https://metacpan.org/author/DRTECH" class="author-name">Clinton Gormley</a>
  </span>
  <span>&nbsp;/&nbsp;</span>
  <div class="release dist-release status-latest maturity-released">
    <span class="dropdown"><b class="caret"></b></span>
<select onchange="document.location.href=&#39;/release/&#39;+this.value+&#39;/view/lib/HTML/StripScripts.pm&#39;" class="">
<option
  selected
  value="DRTECH/HTML-StripScripts-1.06"
>1.06
  (DRTECH on 2016-05-12)</option>
<optgroup label="BackPAN">'
<option
  
  value="DRTECH/HTML-StripScripts-1.05"
>1.05
  (DRTECH on 2009-11-05)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.04"
>1.04
  (DRTECH on 2007-11-16)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.03"
>1.03
  (DRTECH on 2007-10-22)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.02"
>1.02
  (DRTECH on 2007-10-22)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.01"
>1.01
  (DRTECH on 2007-10-22)</option>
<option
  
  value="DRTECH/HTML-StripScripts-1.00"
>1.00
  (DRTECH on 2007-06-05)</option>
<option
  
  value="DRTECH/HTML-StripScripts-0.991"
>0.991
  (DRTECH on 2007-05-29)</option>
<option
  
  value="DRTECH/HTML-StripScripts-0.99"
>0.99
  (DRTECH on 2007-05-28)</option>
<option
  
  value="DRTECH/HTML-StripScripts-0.90"
>0.90
  (DRTECH on 2007-05-28)</option>
<option
  
  value="NCLEATON/HTML-StripScripts-0.03"
>0.03
  (NCLEATON on 2004-04-27)</option>
<option
  
  value="NCLEATON/HTML-StripScripts-0.02"
>0.02
  (NCLEATON on 2003-07-25)</option>
<option
  
  value="NCLEATON/HTML-StripScripts-0.01"
>0.01
  (NCLEATON on 2003-03-30)</option>
</optgroup>
</select>
    <a data-keyboard-shortcut="g d" class="release-name" href="https://metacpan.org/dist/HTML-StripScripts">HTML-StripScripts-1.06</a>
  </div>
<span class="river-gauge-gauge">
  <svg width="24px"
       height="15px"
       version="1.1"
       xmlns="http://www.w3.org/2000/svg"
       xmlns:xlink="http://www.w3.org/1999/xlink">

    <g>
      <title>        River stage two &#10;
          • 4 direct dependents &#10;          • 16 total dependents
      </title>

      <rect x="0"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="5"  y="0" width="4" height="15" fill="#7ea3f2" />
      <rect x="10"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="15"  y="0" width="4" height="15" fill="#e4e2e2" />
      <rect x="20"  y="0" width="4" height="15" fill="#e4e2e2" />
    </g>
  </svg>

</span>
<div id="HTML-StripScripts-fav" class="logged_in">
<form action="https://metacpan.org/account/favorite/add" style="display: inline" onsubmit="return favDistribution(this)">
    <input type="hidden" name="remove" value="0">
    <input type="hidden" name="release" value="HTML-StripScripts-1.06">
    <input type="hidden" name="author" value="DRTECH">
    <input type="hidden" name="distribution" value="HTML-StripScripts">
    <button type="submit" class="favorite"><span></span> ++</button>
</form>
</div>
<div class="logged_out">
<a href="./HTML::StripScripts.html" onclick="alert('Please sign in to add favorites'); return false" class="favorite">
<span></span> ++</a>
</div>
   / <span>HTML::StripScripts</span>
</div>
          </div>
          <main class="content">


<nav class="toc">
  <div class="toc-header"><strong>Contents</strong></div>
<ul>
  <li><a href="./HTML::StripScripts.html#NAME">NAME</a></li>
  <li><a href="./HTML::StripScripts.html#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="./HTML::StripScripts.html#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="./HTML::StripScripts.html#CONSTRUCTORS">CONSTRUCTORS</a></li>
  <li><a href="./HTML::StripScripts.html#METHODS">METHODS</a></li>
  <li><a href="./HTML::StripScripts.html#SUBCLASSING">SUBCLASSING</a></li>
  <li><a href="./HTML::StripScripts.html#OUTPUT-METHODS">OUTPUT METHODS</a></li>
  <li><a href="./HTML::StripScripts.html#REJECT-METHODS">REJECT METHODS</a></li>
  <li><a href="./HTML::StripScripts.html#WHITELIST-INITIALIZATION-METHODS">WHITELIST INITIALIZATION METHODS</a></li>
  <li><a href="./HTML::StripScripts.html#CHARACTER-DATA-PROCESSING">CHARACTER DATA PROCESSING</a></li>
  <li><a href="./HTML::StripScripts.html#OTHER-METHODS-TO-OVERRIDE">OTHER METHODS TO OVERRIDE</a></li>
  <li><a href="./HTML::StripScripts.html#ATTRIBUTE-VALUE-HANDLER-SUBS">ATTRIBUTE VALUE HANDLER SUBS</a></li>
  <li><a href="./HTML::StripScripts.html#CANONICAL-FORM">CANONICAL FORM</a></li>
  <li><a href="./HTML::StripScripts.html#PRIVATE-METHODS">PRIVATE METHODS</a></li>
  <li><a href="./HTML::StripScripts.html#BUGS-AND-LIMITATIONS">BUGS AND LIMITATIONS</a></li>
  <li><a href="./HTML::StripScripts.html#SEE-ALSO">SEE ALSO</a></li>
  <li><a href="./HTML::StripScripts.html#AUTHOR">AUTHOR</a></li>
  <li><a href="./HTML::StripScripts.html#COPYRIGHT">COPYRIGHT</a></li>
  <li><a href="./HTML::StripScripts.html#LICENSE">LICENSE</a></li>
</ul></nav>
<div class="pod anchors">
<h1 id="NAME">NAME</h1>

<p>HTML::StripScripts - Strip scripting constructs out of HTML</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>  use HTML::StripScripts;

  my $hss = HTML::StripScripts-&gt;new({ Context =&gt; &#39;Inline&#39; });

  $hss-&gt;input_start_document;

  $hss-&gt;input_start(&#39;&lt;i&gt;&#39;);
  $hss-&gt;input_text(&#39;hello, world!&#39;);
  $hss-&gt;input_end(&#39;&lt;/i&gt;&#39;);

  $hss-&gt;input_end_document;

  print $hss-&gt;filtered_document;</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>This module strips scripting constructs out of HTML, leaving as much non-scripting markup in place as possible. This allows web applications to display HTML originating from an untrusted source without introducing XSS (cross site scripting) vulnerabilities.</p>

<p>You will probably use <a href="https://metacpan.org/pod/HTML::StripScripts::Parser">HTML::StripScripts::Parser</a> rather than using this module directly.</p>

<p>The process is based on whitelists of tags, attributes and attribute values. This approach is the most secure against disguised scripting constructs hidden in malicious HTML documents.</p>

<p>As well as removing scripting constructs, this module ensures that there is a matching end for each start tag, and that the tags are properly nested.</p>

<p>Previously, in order to customise the output, you needed to subclass <code>HTML::StripScripts</code> and override methods. Now, most customisation can be done through the <code>Rules</code> option provided to <code>new()</code>. (See examples/declaration/ and examples/tags/ for cases where subclassing is necessary.)</p>

<p>The HTML document must be parsed into start tags, end tags and text before it can be filtered by this module. Use either <a href="https://metacpan.org/pod/HTML::StripScripts::Parser">HTML::StripScripts::Parser</a> or <a href="https://metacpan.org/pod/HTML::StripScripts::Regex">HTML::StripScripts::Regex</a> instead if you want to input an unparsed HTML document.</p>

<p>See examples/direct/ for an example of how to feed tokens directly to HTML::StripScripts.</p>

<h1 id="CONSTRUCTORS">CONSTRUCTORS</h1>

<dl>

<dt id="new-(-CONFIG-)"><a id="new"></a><a id="new---CONFIG"></a>new ( CONFIG )</dt>
<dd>

<p>Creates a new <code>HTML::StripScripts</code> filter object, bound to a particular filtering policy. If present, the CONFIG parameter must be a hashref. The following keys are recognized (unrecognized keys will be silently ignored).</p>

<pre><code>    $s = HTML::Stripscripts-&gt;new({
        Context         =&gt; &#39;Document|Flow|Inline|NoTags&#39;,
        BanList         =&gt; [qw( br img )] | {br =&gt; &#39;1&#39;, img =&gt; &#39;1&#39;},
        BanAllBut       =&gt; [qw(p div span)],
        AllowSrc        =&gt; 0|1,
        AllowHref       =&gt; 0|1,
        AllowRelURL     =&gt; 0|1,
        AllowMailto     =&gt; 0|1,
        EscapeFiltered  =&gt; 0|1,
        Rules           =&gt; { See below for details },
    });</code></pre>

<dl>

<dt id="Context"><code>Context</code></dt>
<dd>

<p>A string specifying the context in which the filtered document will be used. This influences the set of tags that will be allowed.</p>

<p>If present, the <code>Context</code> value must be one of:</p>

<dl>

<dt id="Document"><code>Document</code></dt>
<dd>

<p>If <code>Context</code> is <code>Document</code> then the filter will allow a full HTML document, including the <code>HTML</code> tag and <code>HEAD</code> and <code>BODY</code> sections.</p>

</dd>
<dt id="Flow"><code>Flow</code></dt>
<dd>

<p>If <code>Context</code> is <code>Flow</code> then most of the cosmetic tags that one would expect to find in a document body are allowed, including lists and tables but not including forms.</p>

</dd>
<dt id="Inline"><code>Inline</code></dt>
<dd>

<p>If <code>Context</code> is <code>Inline</code> then only inline tags such as <code>B</code> and <code>FONT</code> are allowed.</p>

</dd>
<dt id="NoTags"><code>NoTags</code></dt>
<dd>

<p>If <code>Context</code> is <code>NoTags</code> then no tags are allowed.</p>

</dd>
</dl>

<p>The default <code>Context</code> value is <code>Flow</code>.</p>

</dd>
<dt id="BanList"><code>BanList</code></dt>
<dd>

<p>If present, this option must be an arrayref or a hashref. Any tag that would normally be allowed (because it presents no XSS hazard) will be blocked if the lowercase name of the tag is in this list.</p>

<p>For example, in a guestbook application where <code>HR</code> tags are used to separate posts, you may wish to prevent posts from including <code>HR</code> tags, even though <code>HR</code> is not an XSS risk.</p>

</dd>
<dt id="BanAllBut"><code>BanAllBut</code></dt>
<dd>

<p>If present, this option must be reference to an array holding a list of lowercase tag names. This has the effect of adding all but the listed tags to the ban list, so that only those tags listed will be allowed.</p>

</dd>
<dt id="AllowSrc"><code>AllowSrc</code></dt>
<dd>

<p>By default, the filter won&#39;t allow constructs that cause the browser to fetch things automatically, such as <code>SRC</code> attributes in <code>IMG</code> tags. If this option is present and true then those constructs will be allowed.</p>

</dd>
<dt id="AllowHref"><code>AllowHref</code></dt>
<dd>

<p>By default, the filter won&#39;t allow constructs that cause the browser to fetch things if the user clicks on something, such as the <code>HREF</code> attribute in <code>A</code> tags. Set this option to a true value to allow this type of construct.</p>

</dd>
<dt id="AllowRelURL"><code>AllowRelURL</code></dt>
<dd>

<p>By default, the filter won&#39;t allow relative URLs such as <code>../foo.html</code> in <code>SRC</code> and <code>HREF</code> attribute values. Set this option to a true value to allow them. <code>AllowHref</code> and / or <code>AllowSrc</code> also need to be set to true for this to have any effect.</p>

</dd>
<dt id="AllowMailto"><code>AllowMailto</code></dt>
<dd>

<p>By default, <code>mailto:</code> links are not allowed. If <code>AllowMailto</code> is set to a true value, then this construct will be allowed. This can be enabled separately from AllowHref.</p>

</dd>
<dt id="EscapeFiltered"><code>EscapeFiltered</code></dt>
<dd>

<p>By default, any filtered tags are outputted as <code>&lt;!--filtered--&gt;</code>. If <code>EscapeFiltered</code> is set to a true value, then the filtered tags are converted to HTML entities.</p>

<p>For instance:</p>

<pre><code>  &lt;br&gt;  --&gt;  &amp;lt;br&amp;gt;</code></pre>

</dd>
<dt id="Rules"><code>Rules</code></dt>
<dd>

<p>The <code>Rules</code> option provides a very flexible way of customising the filter.</p>

<p>The focus is safety-first, so it is applied after all of the previous validation. This means that you cannot all malicious data should already have been cleared.</p>

<p>Rules can be specified for tags and for attributes. Any tag or attribute not explicitly listed will be handled by the default <code>*</code> rules.</p>

<p>The following is a synopsis of all of the options that you can use to configure rules. Below, an example is broken into sections and explained.</p>

<pre><code> Rules =&gt; {

     tag =&gt; 0 | 1 | sub { tag_callback }
            | {
                attr      =&gt; 0 | 1 | &#39;regex&#39; | qr/regex/ | sub { attr_callback},
                &#39;*&#39;       =&gt; 0 | 1 | &#39;regex&#39; | qr/regex/ | sub { attr_callback},
                required  =&gt; [qw(attrname attrname)],
                tag       =&gt; sub { tag_callback }
              },

    &#39;*&#39; =&gt; 0 | 1 | sub { tag_callback }
           | {
               attr =&gt; 0 | 1 | &#39;regex&#39; | qr/regex/ | sub { attr_callback},
               &#39;*&#39;  =&gt; 0 | 1 | &#39;regex&#39; | qr/regex/ | sub { attr_callback},
               tag  =&gt; sub { tag_callback }
             }

    }</code></pre>

<p>EXAMPLE:</p>

<pre><code>    Rules =&gt; {

        ##########################
        ##### EXPLICIT RULES #####
        ##########################

        ## Allow &lt;br&gt; tags, reject &lt;img&gt; tags
        br          =&gt; 1,
        img         =&gt; 0,

        ## Send all &lt;div&gt; tags to a sub
        div         =&gt; sub { tag_callback },

        ## Allow &lt;blockquote&gt; tags,and allow the &#39;cite&#39; attribute
        ## All other attributes are handled by the default C&lt;*&gt;
        blockquote  =&gt; {
            cite    =&gt; 1,
        },

        ## Allow &lt;a&gt; tags, and
        a  =&gt; {

            ## Allow the &#39;title&#39; attribute
            title     =&gt; 1,

            ## Allow the &#39;href&#39; attribute if it matches the regex
            href    =&gt;   &#39;^http://yourdomain.com&#39;
       OR   href    =&gt; qr{^http://yourdomain.com},

            ## &#39;style&#39; attributes are handled by a sub
            style     =&gt; sub { attr_callback },

            ## All other attributes are rejected
            &#39;*&#39;       =&gt; 0,

            ## Additionally, the &lt;a&gt; tag should be handled by this sub
            tag       =&gt; sub { tag_callback},

            ## If the &lt;a&gt; tag doesn&#39;t have these attributes, filter the tag
            required  =&gt; [qw(href title)],

        },

        ##########################
        ##### DEFAULT RULES #####
        ##########################

        ## The default &#39;*&#39; rule - accepts all the same options as above.
        ## If a tag or attribute is not mentioned above, then the default
        ## rule is applied:

        ## Reject all tags
        &#39;*&#39;         =&gt; 0,

        ## Allow all tags and all attributes
        &#39;*&#39;         =&gt; 1,

        ## Send all tags to the sub
        &#39;*&#39;         =&gt; sub { tag_callback },

        ## Allow all tags, reject all attributes
        &#39;*&#39;         =&gt; { &#39;*&#39;  =&gt; 0 },

        ## Allow all tags, and
        &#39;*&#39; =&gt; {

            ## Allow the &#39;title&#39; attribute
            title   =&gt; 1,

            ## Allow the &#39;href&#39; attribute if it matches the regex
            href    =&gt;   &#39;^http://yourdomain.com&#39;
       OR   href    =&gt; qr{^http://yourdomain.com},

            ## &#39;style&#39; attributes are handled by a sub
            style   =&gt; sub { attr_callback },

            ## All other attributes are rejected
            &#39;*&#39;     =&gt; 0,

            ## Additionally, all tags should be handled by this sub
            tag     =&gt; sub { tag_callback},

        },</code></pre>

<dl>

<dt id="Tag-Callbacks"><a id="Tag"></a>Tag Callbacks</dt>
<dd>

<pre><code>    sub tag_callback {
        my ($filter,$element) = (@_);

        $element = {
            tag      =&gt; &#39;tag&#39;,
            content  =&gt; &#39;inner_html&#39;,
            attr     =&gt; {
                attr_name =&gt; &#39;attr_value&#39;,
            }
        };
        return 0 | 1;
    }</code></pre>

<p>A tag callback accepts two parameters, the <code>$filter</code> object and the C$element&gt;. It should return <code>0</code> to completely ignore the tag and its content (which includes any nested HTML tags), or <code>1</code> to accept and output the tag.</p>

<p>The <code>$element</code> is a hash ref containing the keys:</p>

</dd>
<dt id="tag"><code>tag</code></dt>
<dd>

<p>This is the tagname in lowercase, eg <code>a</code>, <code>br</code>, <code>img</code>. If you set the tag value to an empty string, then the tag will not be outputted, but the tag contents will.</p>

</dd>
<dt id="content"><code>content</code></dt>
<dd>

<p>This is the equivalent of DOM&#39;s innerHTML. It contains the text content and any HTML tags contained within this element. You can change the content or set it to an empty string so that it is not outputted.</p>

</dd>
<dt id="attr"><code>attr</code></dt>
<dd>

<p><code>attr</code> contains a hashref containing the attribute names and values</p>

</dd>
</dl>

<p>If for instance, you wanted to replace <code>&lt;b&gt;</code> tags with <code>&lt;span&gt;</code> tags, you could do this:</p>

<pre><code>    sub b_callback {
        my ($filter,$element)   = @_;
        $element-&gt;{tag}         = &#39;span&#39;;
        $element-&gt;{attr}{style} = &#39;font-weight:bold&#39;;
        return 1;
    }</code></pre>

</dd>
<dt id="Attribute-Callbacks"><a id="Attribute"></a>Attribute Callbacks</dt>
<dd>

<pre><code>    sub attr_callback {
        my ( $filter, $tag, $attr_name, $attr_val ) = @_;
        return undef | &#39;&#39; | &#39;value&#39;;
    }</code></pre>

<p>Attribute callbacks accept four parameters, the <code>$filter</code> object, the <code>$tag</code> name, the <code>$attr_name</code> and the <code>$attr_value</code>.</p>

<p>It should return either <code>undef</code> to reject the attribute, or the value to be used. An empty string keeps the attribute, but without a value.</p>

</dd>
<dt id="BanList-vs-BanAllBut-vs-Rules"><a id="BanList1"></a><code>BanList</code> vs <code>BanAllBut</code> vs <code>Rules</code></dt>
<dd>

<p>It is not necessary to use <code>BanList</code> or <code>BanAllBut</code> - everything can be done via <code>Rules</code>, however it may be simpler to write:</p>

<pre><code>    BanAllBut =&gt; [qw(p div span)]</code></pre>

<p>The logic works as follows:</p>

<pre><code>   * If BanAllBut exists, then ban everything but the tags in the list
   * Add to the ban list any elements in BanList
   * Any tags mentioned explicitly in Rules (eg a =&gt; 0, br =&gt; 1)
     are added or removed from the BanList
   * A default rule of { &#39;*&#39; =&gt; 0 } would ban all tags except
     those mentioned in Rules
   * A default rule of { &#39;*&#39; =&gt; 1 } would allow all tags except
     those disallowed in the ban list, or by explicit rules</code></pre>

</dd>
</dl>

</dd>
</dl>

<h1 id="METHODS">METHODS</h1>

<p>This class provides the following methods:</p>

<dl>

<dt id="hss_init-()"><a id="hss_init"></a>hss_init ()</dt>
<dd>

<p>This method is called by new() and does the actual initialisation work for the new HTML::StripScripts object.</p>

</dd>
<dt id="input_start_document-()"><a id="input_start_document"></a>input_start_document ()</dt>
<dd>

<p>This method initializes the filter, and must be called once before starting on each HTML document to be filtered.</p>

</dd>
<dt id="input_start-(-TEXT-)"><a id="input_start"></a><a id="input_start---TEXT"></a>input_start ( TEXT )</dt>
<dd>

<p>Handles a start tag from the input document. TEXT must be the full text of the tag, including angle-brackets.</p>

</dd>
<dt id="input_end-(-TEXT-)"><a id="input_end"></a><a id="input_end---TEXT"></a>input_end ( TEXT )</dt>
<dd>

<p>Handles an end tag from the input document. TEXT must be the full text of the end tag, including angle-brackets.</p>

</dd>
<dt id="input_text-(-TEXT-)"><a id="input_text"></a><a id="input_text---TEXT"></a>input_text ( TEXT )</dt>
<dd>

<p>Handles some non-tag text from the input document.</p>

</dd>
<dt id="input_process-(-TEXT-)"><a id="input_process"></a><a id="input_process---TEXT"></a>input_process ( TEXT )</dt>
<dd>

<p>Handles a processing instruction from the input document.</p>

</dd>
<dt id="input_comment-(-TEXT-)"><a id="input_comment"></a><a id="input_comment---TEXT"></a>input_comment ( TEXT )</dt>
<dd>

<p>Handles an HTML comment from the input document.</p>

</dd>
<dt id="input_declaration-(-TEXT-)"><a id="input_declaration"></a><a id="input_declaration---TEXT"></a>input_declaration ( TEXT )</dt>
<dd>

<p>Handles an declaration from the input document.</p>

</dd>
<dt id="input_end_document-()"><a id="input_end_document"></a>input_end_document ()</dt>
<dd>

<p>Call this method to signal the end of the input document.</p>

</dd>
<dt id="filtered_document-()"><a id="filtered_document"></a>filtered_document ()</dt>
<dd>

<p>Returns the filtered document as a string.</p>

</dd>
</dl>

<h1 id="SUBCLASSING">SUBCLASSING</h1>

<p>The only reason for subclassing this module now is to add to the list of accepted tags, attributes and styles (See <a href="./HTML::StripScripts.html#WHITELIST-INITIALIZATION-METHODS">&quot;WHITELIST INITIALIZATION METHODS&quot;</a>). Everything else can be achieved with <a href="./HTML::StripScripts.html#Rules">&quot;Rules&quot;</a>.</p>

<p>The <code>HTML::StripScripts</code> class is subclassable. Filter objects are plain hashes and <code>HTML::StripScripts</code> reserves only hash keys that start with <code>_hss</code>. The filter configuration can be set up by invoking the hss_init() method, which takes the same arguments as new().</p>

<h1 id="OUTPUT-METHODS"><a id="OUTPUT"></a>OUTPUT METHODS</h1>

<p>The filter outputs a stream of start tags, end tags, text, comments, declarations and processing instructions, via the following <code>output_*</code> methods. Subclasses may override these to intercept the filter output.</p>

<p>The default implementations of the <code>output_*</code> methods pass the text on to the output() method. The default implementation of the output() method appends the text to a string, which can be fetched with the filtered_document() method once processing is complete.</p>

<p>If the output() method or the individual <code>output_*</code> methods are overridden in a subclass, then filtered_document() will not work in that subclass.</p>

<dl>

<dt id="output_start_document-()"><a id="output_start_document"></a>output_start_document ()</dt>
<dd>

<p>This method gets called once at the start of each HTML document passed through the filter. The default implementation does nothing.</p>

</dd>
<dt id="output_end_document-()"><a id="output_end_document"></a>output_end_document ()</dt>
<dd>

<p>This method gets called once at the end of each HTML document passed through the filter. The default implementation does nothing.</p>

</dd>
<dt id="output_start-(-TEXT-)"><a id="output_start"></a><a id="output_start---TEXT"></a>output_start ( TEXT )</dt>
<dd>

<p>This method is used to output a filtered start tag.</p>

</dd>
<dt id="output_end-(-TEXT-)"><a id="output_end"></a><a id="output_end---TEXT"></a>output_end ( TEXT )</dt>
<dd>

<p>This method is used to output a filtered end tag.</p>

</dd>
<dt id="output_text-(-TEXT-)"><a id="output_text"></a><a id="output_text---TEXT"></a>output_text ( TEXT )</dt>
<dd>

<p>This method is used to output some filtered non-tag text.</p>

</dd>
<dt id="output_declaration-(-TEXT-)"><a id="output_declaration"></a><a id="output_declaration---TEXT"></a>output_declaration ( TEXT )</dt>
<dd>

<p>This method is used to output a filtered declaration.</p>

</dd>
<dt id="output_comment-(-TEXT-)"><a id="output_comment"></a><a id="output_comment---TEXT"></a>output_comment ( TEXT )</dt>
<dd>

<p>This method is used to output a filtered HTML comment.</p>

</dd>
<dt id="output_process-(-TEXT-)"><a id="output_process"></a><a id="output_process---TEXT"></a>output_process ( TEXT )</dt>
<dd>

<p>This method is used to output a filtered processing instruction.</p>

</dd>
<dt id="output-(-TEXT-)"><a id="output"></a><a id="output---TEXT"></a>output ( TEXT )</dt>
<dd>

<p>This method is invoked by all of the default <code>output_*</code> methods. The default implementation appends the text to the string that the filtered_document() method will return.</p>

</dd>
<dt id="output_stack_entry-(-TEXT-)"><a id="output_stack_entry"></a><a id="output_stack_entry---TEXT"></a>output_stack_entry ( TEXT )</dt>
<dd>

<p>This method is invoked when a tag plus all text and nested HTML content within the tag has been processed. It adds the tag plus its content to the content for its parent tag.</p>

</dd>
</dl>

<h1 id="REJECT-METHODS"><a id="REJECT"></a>REJECT METHODS</h1>

<p>When the filter encounters something in the input document which it cannot transform into an acceptable construct, it invokes one of the following <code>reject_*</code> methods to put something in the output document to take the place of the unacceptable construct.</p>

<p>The TEXT parameter is the full text of the unacceptable construct.</p>

<p>The default implementations of these methods output an HTML comment containing the text <code>filtered</code>. If <a href="./HTML::StripScripts.html#EscapeFiltered">&quot;EscapeFiltered&quot;</a> is set to true, then the rejected text is HTML escaped instead.</p>

<p>Subclasses may override these methods, but should exercise caution. The TEXT parameter is unfiltered input and may contain malicious constructs.</p>

<dl>

<dt id="reject_start-(-TEXT-)"><a id="reject_start"></a><a id="reject_start---TEXT"></a>reject_start ( TEXT )</dt>
<dd>

</dd>
<dt id="reject_end-(-TEXT-)"><a id="reject_end"></a><a id="reject_end---TEXT"></a>reject_end ( TEXT )</dt>
<dd>

</dd>
<dt id="reject_text-(-TEXT-)"><a id="reject_text"></a><a id="reject_text---TEXT"></a>reject_text ( TEXT )</dt>
<dd>

</dd>
<dt id="reject_declaration-(-TEXT-)"><a id="reject_declaration"></a><a id="reject_declaration---TEXT"></a>reject_declaration ( TEXT )</dt>
<dd>

</dd>
<dt id="reject_comment-(-TEXT-)"><a id="reject_comment"></a><a id="reject_comment---TEXT"></a>reject_comment ( TEXT )</dt>
<dd>

</dd>
<dt id="reject_process-(-TEXT-)"><a id="reject_process"></a><a id="reject_process---TEXT"></a>reject_process ( TEXT )</dt>
<dd>

</dd>
</dl>

<h1 id="WHITELIST-INITIALIZATION-METHODS"><a id="WHITELIST"></a>WHITELIST INITIALIZATION METHODS</h1>

<p>The filter refers to various whitelists to determine which constructs are acceptable. To modify these whitelists, subclasses can override the following methods.</p>

<p>Each method is called once at object initialization time, and must return a reference to a nested data structure. These references are installed into the object, and used whenever the filter needs to refer to a whitelist.</p>

<p>The default implementations of these methods can be invoked as class methods.</p>

<p>See examples/tags/ and examples/declaration/ for examples of how to override these methods.</p>

<dl>

<dt id="init_context_whitelist-()"><a id="init_context_whitelist"></a>init_context_whitelist ()</dt>
<dd>

<p>Returns a reference to the <code>Context</code> whitelist, which determines which tags may appear at each point in the document, and which other tags may be nested within them.</p>

<p>It is a hash, and the keys are context names, such as <code>Flow</code> and <code>Inline</code>.</p>

<p>The values in the hash are hashrefs. The keys in these subhashes are lowercase tag names, and the values are context names, specifying the context that the tag provides to any other tags nested within it.</p>

<p>The special context <code>EMPTY</code> as a value in a subhash indicates that nothing can be nested within that tag.</p>

</dd>
<dt id="init_attrib_whitelist-()"><a id="init_attrib_whitelist"></a>init_attrib_whitelist ()</dt>
<dd>

<p>Returns a reference to the <code>Attrib</code> whitelist, which determines which attributes each tag can have and the values that those attributes can take.</p>

<p>It is a hash, and the keys are lowercase tag names.</p>

<p>The values in the hash are hashrefs. The keys in these subhashes are lowercase attribute names, and the values are attribute value class names, which are short strings describing the type of values that the attribute can take, such as <code>color</code> or <code>number</code>.</p>

</dd>
<dt id="init_attval_whitelist-()"><a id="init_attval_whitelist"></a>init_attval_whitelist ()</dt>
<dd>

<p>Returns a reference to the <code>AttVal</code> whitelist, which is a hash that maps attribute value class names from the <code>Attrib</code> whitelist to coderefs to subs to validate (and optionally transform) a particular attribute value.</p>

<p>The filter calls the attribute value validation subs with the following parameters:</p>

<dl>

<dt id="filter"><code>filter</code></dt>
<dd>

<p>A reference to the filter object.</p>

</dd>
<dt id="tagname"><code>tagname</code></dt>
<dd>

<p>The lowercase name of the tag in which the attribute appears.</p>

</dd>
<dt id="attrname"><code>attrname</code></dt>
<dd>

<p>The name of the attribute.</p>

</dd>
<dt id="attrval"><code>attrval</code></dt>
<dd>

<p>The attribute value found in the input document, in canonical form (see <a href="./HTML::StripScripts.html#CANONICAL-FORM">&quot;CANONICAL FORM&quot;</a>).</p>

</dd>
</dl>

<p>The validation sub can return undef to indicate that the attribute should be removed from the tag, or it can return the new value for the attribute, in canonical form.</p>

</dd>
<dt id="init_style_whitelist-()"><a id="init_style_whitelist"></a>init_style_whitelist ()</dt>
<dd>

<p>Returns a reference to the <code>Style</code> whitelist, which determines which CSS style directives are permitted in <code>style</code> tag attributes. The keys are value names such as <code>color</code> and <code>background-color</code>, and the values are class names to be used as keys into the <code>AttVal</code> whitelist.</p>

</dd>
<dt id="init_deinter_whitelist">init_deinter_whitelist</dt>
<dd>

<p>Returns a reference to the <code>DeInter</code> whitelist, which determines which inline tags the filter should attempt to automatically de-interleave if they are encountered interleaved. For example, the filter will transform:</p>

<pre><code>  &lt;b&gt;hello &lt;i&gt;world&lt;/b&gt; !&lt;/i&gt;</code></pre>

<p>Into:</p>

<pre><code>  &lt;b&gt;hello &lt;i&gt;world&lt;/i&gt;&lt;/b&gt;&lt;i&gt; !&lt;/i&gt;</code></pre>

<p>because both <code>b</code> and <code>i</code> appear as keys in the <code>DeInter</code> whitelist.</p>

</dd>
</dl>

<h1 id="CHARACTER-DATA-PROCESSING"><a id="CHARACTER"></a>CHARACTER DATA PROCESSING</h1>

<p>These methods transform attribute values and non-tag text from the input document into canonical form (see <a href="./HTML::StripScripts.html#CANONICAL-FORM">&quot;CANONICAL FORM&quot;</a>), and transform text in canonical form into a suitable form for the output document.</p>

<dl>

<dt id="text_to_canonical_form-(-TEXT-)"><a id="text_to_canonical_form"></a><a id="text_to_canonical_form---TEXT"></a>text_to_canonical_form ( TEXT )</dt>
<dd>

<p>This method is used to reduce non-tag text from the input document to canonical form before passing it to the filter_text() method.</p>

<p>The default implementation unescapes all entities that map to <code>US-ASCII</code> characters other than ampersand, and replaces any ampersands that don&#39;t form part of valid entities with <code>&amp;amp;</code>.</p>

</dd>
<dt id="quoted_to_canonical_form-(-VALUE-)"><a id="quoted_to_canonical_form"></a><a id="quoted_to_canonical_form---VALUE"></a>quoted_to_canonical_form ( VALUE )</dt>
<dd>

<p>This method is used to reduce attribute values quoted with doublequotes or singlequotes to canonical form before passing it to the handler subs in the <code>AttVal</code> whitelist.</p>

<p>The default behavior is the same as that of <code>text_to_canonical_form()</code>, plus it converts any CR, LF or TAB characters to spaces.</p>

</dd>
<dt id="unquoted_to_canonical_form-(-VALUE-)"><a id="unquoted_to_canonical_form"></a><a id="unquoted_to_canonical_form---VALUE"></a>unquoted_to_canonical_form ( VALUE )</dt>
<dd>

<p>This method is used to reduce attribute values without quotes to canonical form before passing it to the handler subs in the <code>AttVal</code> whitelist.</p>

<p>The default implementation simply replaces all ampersands with <code>&amp;amp;</code>, since that corresponds with the way most browsers treat entities in unquoted values.</p>

</dd>
<dt id="canonical_form_to_text-(-TEXT-)"><a id="canonical_form_to_text"></a><a id="canonical_form_to_text---TEXT"></a>canonical_form_to_text ( TEXT )</dt>
<dd>

<p>This method is used to convert the text in canonical form returned by the filter_text() method to a form suitable for inclusion in the output document.</p>

<p>The default implementation runs anything that doesn&#39;t look like a valid entity through the escape_html_metachars() method.</p>

</dd>
<dt id="canonical_form_to_attval-(-ATTVAL-)"><a id="canonical_form_to_attval"></a><a id="canonical_form_to_attval---ATTVAL"></a>canonical_form_to_attval ( ATTVAL )</dt>
<dd>

<p>This method is used to convert the text in canonical form returned by the <code>AttVal</code> handler subs to a form suitable for inclusion in doublequotes in the output tag.</p>

<p>The default implementation converts CR, LF and TAB characters to a single space, and runs anything that doesn&#39;t look like a valid entity through the escape_html_metachars() method.</p>

</dd>
<dt id="validate_href_attribute-(-TEXT-)"><a id="validate_href_attribute"></a><a id="validate_href_attribute---TEXT"></a>validate_href_attribute ( TEXT )</dt>
<dd>

<p>If the <code>AllowHref</code> filter configuration option is set, then this method is used to validate <code>href</code> type attribute values. TEXT is the attribute value in canonical form. Returns a possibly modified attribute value (in canonical form) or <code>undef</code> to reject the attribute.</p>

<p>The default implementation allows only absolute <code>http</code> and <code>https</code> URLs, permits port numbers and query strings, and imposes reasonable length limits.</p>

<p>It does not URI escape the query string, and it does not guarantee properly formatted URIs, it just tries to give safe URIs. You can always use an attribute callback (see <a href="./HTML::StripScripts.html#Attribute-Callbacks">&quot;Attribute Callbacks&quot;</a>) to provide stricter handling.</p>

</dd>
<dt id="validate_mailto-(-TEXT-)"><a id="validate_mailto"></a><a id="validate_mailto---TEXT"></a>validate_mailto ( TEXT )</dt>
<dd>

<p>If the <code>AllowMailto</code> filter configuration option is set, then this method is used to validate <code>href</code> type attribute values which begin with <code>mailto:</code>. TEXT is the attribute value in canonical form. Returns a possibly modified attribute value (in canonical form) or <code>undef</code> to reject the attribute.</p>

<p>This uses a lightweight regex and does not guarantee that email addresses are properly formatted. You can always use an attribute callback (see <a href="./HTML::StripScripts.html#Attribute-Callbacks">&quot;Attribute Callbacks&quot;</a>) to provide stricter handling.</p>

</dd>
<dt id="validate_src_attribute-(-TEXT-)"><a id="validate_src_attribute"></a><a id="validate_src_attribute---TEXT"></a>validate_src_attribute ( TEXT )</dt>
<dd>

<p>If the <code>AllowSrc</code> filter configuration option is set, then this method is used to validate <code>src</code> type attribute values. TEXT is the attribute value in canonical form. Returns a possibly modified attribute value (in canonical form) or <code>undef</code> to reject the attribute.</p>

<p>The default implementation behaves as validate_href_attribute().</p>

</dd>
</dl>

<h1 id="OTHER-METHODS-TO-OVERRIDE"><a id="OTHER"></a>OTHER METHODS TO OVERRIDE</h1>

<p>As well as the output, reject, init and cdata methods listed above, it might make sense for subclasses to override the following methods:</p>

<dl>

<dt id="filter_text-(-TEXT-)"><a id="filter_text"></a><a id="filter_text---TEXT"></a>filter_text ( TEXT )</dt>
<dd>

<p>This method will be invoked to filter blocks of non-tag text in the input document. Both input and output are in canonical form, see <a href="./HTML::StripScripts.html#CANONICAL-FORM">&quot;CANONICAL FORM&quot;</a>.</p>

<p>The default implementation does no filtering.</p>

</dd>
<dt id="escape_html_metachars-(-TEXT-)"><a id="escape_html_metachars"></a><a id="escape_html_metachars---TEXT"></a>escape_html_metachars ( TEXT )</dt>
<dd>

<p>This method is used to escape all HTML metacharacters in TEXT. The return value must be a copy of TEXT with metacharacters escaped.</p>

<p>The default implementation escapes a minimal set of metacharacters for security against XSS vulnerabilities. The set of characters to escape is a compromise between the need for security and the need to ensure that the filter will work for documents in as many different character sets as possible.</p>

<p>Subclasses which make strong assumptions about the document character set will be able to escape much more aggressively.</p>

</dd>
<dt id="strip_nonprintable-(-TEXT-)"><a id="strip_nonprintable"></a><a id="strip_nonprintable---TEXT"></a>strip_nonprintable ( TEXT )</dt>
<dd>

<p>Returns a copy of TEXT with runs of nonprintable characters replaced with spaces or some other harmless string. Avoids replacing anything with the empty string, as that can lead to other security issues.</p>

<p>The default implementation strips out only NULL characters, in order to avoid scrambling text for as many different character sets as possible.</p>

<p>Subclasses which make some sort of assumption about the character set in use will be able to have a much wider definition of a nonprintable character, and hence a more secure strip_nonprintable() implementation.</p>

</dd>
</dl>

<h1 id="ATTRIBUTE-VALUE-HANDLER-SUBS"><a id="ATTRIBUTE"></a>ATTRIBUTE VALUE HANDLER SUBS</h1>

<p>References to the following subs appear in the <code>AttVal</code> whitelist returned by the init_attval_whitelist() method.</p>

<dl>

<dt id="_hss_attval_style(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_style"></a><a id="hss_attval_style--FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_style( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value hander for the <code>style</code> attribute.</p>

</dd>
<dt id="_hss_attval_size-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_size"></a><a id="hss_attval_size---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_size ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for attributes who&#39;s values are some sort of size or length.</p>

</dd>
<dt id="_hss_attval_number-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_number"></a><a id="hss_attval_number---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_number ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for attributes who&#39;s values are a simple integer.</p>

</dd>
<dt id="_hss_attval_color-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_color"></a><a id="hss_attval_color---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_color ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for color attributes.</p>

</dd>
<dt id="_hss_attval_text-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_text"></a><a id="hss_attval_text---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_text ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for text attributes.</p>

</dd>
<dt id="_hss_attval_word-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_word"></a><a id="hss_attval_word---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_word ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for attributes who&#39;s values must consist of a single short word, with minus characters permitted.</p>

</dd>
<dt id="_hss_attval_wordlist-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_wordlist"></a><a id="hss_attval_wordlist---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_wordlist ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for attributes who&#39;s values must consist of one or more words, separated by spaces and/or commas.</p>

</dd>
<dt id="_hss_attval_wordlistq-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_wordlistq"></a><a id="hss_attval_wordlistq---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_wordlistq ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for attributes who&#39;s values must consist of one or more words, separated by commas, with optional doublequotes around words and spaces allowed within the doublequotes.</p>

</dd>
<dt id="_hss_attval_href-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_href"></a><a id="hss_attval_href---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_href ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for <code>href</code> type attributes. If the <code>AllowHref</code> or <code>AllowMailto</code> configuration options are set, uses the validate_href_attribute() method to check the attribute value.</p>

</dd>
<dt id="_hss_attval_src-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_src"></a><a id="hss_attval_src---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_src ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for <code>src</code> type attributes. If the <code>AllowSrc</code> configuration option is set, uses the validate_src_attribute() method to check the attribute value.</p>

</dd>
<dt id="_hss_attval_stylesrc-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_stylesrc"></a><a id="hss_attval_stylesrc---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_stylesrc ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for <code>src</code> type style pseudo attributes.</p>

</dd>
<dt id="_hss_attval_novalue-(-FILTER,-TAGNAME,-ATTRNAME,-ATTRVAL-)"><a id="_hss_attval_novalue"></a><a id="hss_attval_novalue---FILTER--TAGNAME--ATTRNAME--ATTRVAL"></a>_hss_attval_novalue ( FILTER, TAGNAME, ATTRNAME, ATTRVAL )</dt>
<dd>

<p>Attribute value handler for attributes that have no value or a value that is ignored. Just returns the attribute name as the value.</p>

</dd>
</dl>

<h1 id="CANONICAL-FORM"><a id="CANONICAL"></a>CANONICAL FORM</h1>

<p>Many of the methods described above deal with text from the input document, encoded in what I call <code>canonical form</code>, defined as follows:</p>

<p>All characters other than ampersands represent themselves. Literal ampersands are encoded as <code>&amp;amp;</code>. Non <code>US-ASCII</code> characters may appear as literals in whatever character set is in use, or they may appear as named or numeric HTML entities such as <code>&amp;aelig;</code>, <code>&amp;#31337;</code> and <code>&amp;#xFF;</code>. Unknown named entities such as <code>&amp;foo;</code> may appear.</p>

<p>The idea is to be able to be able to reduce input text to a minimal form, without making too many assumptions about the character set in use.</p>

<h1 id="PRIVATE-METHODS"><a id="PRIVATE"></a>PRIVATE METHODS</h1>

<p>The following methods are internal to this class, and should not be invoked from elsewhere. Subclasses should not use or override these methods.</p>

<dl>

<dt id="_hss_prepare_ban_list-(CFG)"><a id="_hss_prepare_ban_list"></a><a id="hss_prepare_ban_list--CFG"></a>_hss_prepare_ban_list (CFG)</dt>
<dd>

<p>Returns a hash ref representing all the banned tags, based on the values of BanList and BanAllBut</p>

</dd>
<dt id="_hss_prepare_rules-(CFG)"><a id="_hss_prepare_rules"></a><a id="hss_prepare_rules--CFG"></a>_hss_prepare_rules (CFG)</dt>
<dd>

<p>Returns a hash ref representing the tag and attribute rules (See <a href="./HTML::StripScripts.html#Rules">&quot;Rules&quot;</a>).</p>

<p>Returns undef if no filters are specified, in which case the attribute filter code has very little performance impact. If any rules are specified, then every tag and attribute is checked.</p>

</dd>
<dt id="_hss_get_attr_filter-(-DEFAULT_FILTERS-TAG_FILTERS-ATTR_NAME)"><a id="_hss_get_attr_filter"></a><a id="hss_get_attr_filter---DEFAULT_FILTERS-TAG_FILTERS-ATTR_NAME"></a>_hss_get_attr_filter ( DEFAULT_FILTERS TAG_FILTERS ATTR_NAME)</dt>
<dd>

<p>Returns the attribute filter rule to apply to this particular attribute.</p>

<p>Checks for:</p>

<pre><code>  - a named attribute rule in a named tag
  - a default * attribute rule in a named tag
  - a named attribute rule in the default * rules
  - a default * attribute rule in the default * rules</code></pre>

</dd>
<dt id="_hss_join_attribs-(FILTERED_ATTRIBS)"><a id="_hss_join_attribs"></a><a id="hss_join_attribs--FILTERED_ATTRIBS"></a>_hss_join_attribs (FILTERED_ATTRIBS)</dt>
<dd>

<p>Accepts a hash ref containing the attribute names as the keys, and the attribute values as the values. Escapes them and returns a string ready for output to HTML</p>

</dd>
<dt id="_hss_decode_numeric-(-NUMERIC-)"><a id="_hss_decode_numeric"></a><a id="hss_decode_numeric---NUMERIC"></a>_hss_decode_numeric ( NUMERIC )</dt>
<dd>

<p>Returns the string that should replace the numeric entity NUMERIC in the text_to_canonical_form() method.</p>

</dd>
<dt id="_hss_tag_is_banned-(-TAGNAME-)"><a id="_hss_tag_is_banned"></a><a id="hss_tag_is_banned---TAGNAME"></a>_hss_tag_is_banned ( TAGNAME )</dt>
<dd>

<p>Returns true if the lower case tag name TAGNAME is on the list of harmless tags that the filter is configured to block, false otherwise.</p>

</dd>
<dt id="_hss_get_to_valid_context-(-TAG-)"><a id="_hss_get_to_valid_context"></a><a id="hss_get_to_valid_context---TAG"></a>_hss_get_to_valid_context ( TAG )</dt>
<dd>

<p>Tries to get the filter to a context in which the tag TAG is allowed, by introducing extra end tags or start tags if necessary. TAG can be either the lower case name of a tag or the string &#39;CDATA&#39;.</p>

<p>Returns 1 if an allowed context is reached, or 0 if there&#39;s no reasonable way to get to an allowed context and the tag should just be rejected.</p>

</dd>
<dt id="_hss_close_innermost_tag-()"><a id="_hss_close_innermost_tag"></a><a id="hss_close_innermost_tag"></a>_hss_close_innermost_tag ()</dt>
<dd>

<p>Closes the innermost open tag.</p>

</dd>
<dt id="_hss_context-()"><a id="_hss_context"></a><a id="hss_context"></a>_hss_context ()</dt>
<dd>

<p>Returns the current named context of the filter.</p>

</dd>
<dt id="_hss_valid_in_context-(-TAG,-CONTEXT-)"><a id="_hss_valid_in_context"></a><a id="hss_valid_in_context---TAG--CONTEXT"></a>_hss_valid_in_context ( TAG, CONTEXT )</dt>
<dd>

<p>Returns true if the lowercase tag name TAG is valid in context CONTEXT, false otherwise.</p>

</dd>
<dt id="_hss_valid_in_current_context-(-TAG-)"><a id="_hss_valid_in_current_context"></a><a id="hss_valid_in_current_context---TAG"></a>_hss_valid_in_current_context ( TAG )</dt>
<dd>

<p>Returns true if the lowercase tag name TAG is valid in the filter&#39;s current context, false otherwise.</p>

</dd>
</dl>

<h1 id="BUGS-AND-LIMITATIONS"><a id="BUGS"></a>BUGS AND LIMITATIONS</h1>

<dl>

<dt id="Performance">Performance</dt>
<dd>

<p>This module does a lot of work to ensure that tags are correctly nested and are not left open, causing unnecessary overhead for applications where that doesn&#39;t matter.</p>

<p>Such applications may benefit from using the more lightweight <a href="https://metacpan.org/pod/HTML::Scrubber::StripScripts">HTML::Scrubber::StripScripts</a> module instead.</p>

</dd>
<dt id="Strictness">Strictness</dt>
<dd>

<p>URIs and email addresses are cleaned up to be safe, but not necessarily accurate. That would have required adding dependencies. Attribute callbacks can be used to add this functionality if required, or the validation methods can be overridden.</p>

<p>By default, filtered HTML may not be valid strict XHTML, for instance empty required attributes may be outputted. However, with <a href="./HTML::StripScripts.html#Rules">&quot;Rules&quot;</a>, it should be possible to force the HTML to validate.</p>

</dd>
<dt id="REPORTING-BUGS"><a id="REPORTING"></a>REPORTING BUGS</dt>
<dd>

<p>Please report any bugs or feature requests to bug-html-stripscripts@rt.cpan.org, or through the web interface at <a href="http://rt.cpan.org">http://rt.cpan.org</a>.</p>

</dd>
</dl>

<h1 id="SEE-ALSO"><a id="SEE"></a>SEE ALSO</h1>

<p><a href="./HTML::Parser.html">HTML::Parser</a>, <a href="https://metacpan.org/pod/HTML::StripScripts::Parser">HTML::StripScripts::Parser</a>, <a href="https://metacpan.org/pod/HTML::StripScripts::Regex">HTML::StripScripts::Regex</a></p>

<h1 id="AUTHOR">AUTHOR</h1>

<p>Original author Nick Cleaton &lt;nick@cleaton.net&gt;</p>

<p>New code added and module maintained by Clinton Gormley &lt;clint@traveljury.com&gt;</p>

<h1 id="COPYRIGHT">COPYRIGHT</h1>

<p>Copyright (C) 2003 Nick Cleaton. All Rights Reserved.</p>

<p>Copyright (C) 2007 Clinton Gormley. All Rights Reserved.</p>

<h1 id="LICENSE">LICENSE</h1>

<p>This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p></div>

<div id="metacpan_install-instructions-dialog" class="modal fade">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title">Module Install Instructions</h4>
      </div>
      <div class="modal-body">
        <p>To install HTML::StripScripts, copy and paste the appropriate command in to your terminal.</p>
        <p><a href="https://metacpan.org/dist/App-cpanminus/view/bin/cpanm">cpanm</a></p>
        <pre><code>cpanm HTML::StripScripts</code></pre>
        <p><a href="https://metacpan.org/pod/CPAN">CPAN shell</a></p>
        <pre><code>perl -MCPAN -e shell
install HTML::StripScripts</code></pre>
        <p>For more information on module installation, please visit <a href="https://www.cpan.org/modules/INSTALL.html">the detailed CPAN module installation guide</a>.</p>
      </div>
      <div class="modal-footer">
        <a href="./HTML::StripScripts.html#" data-dismiss="modal" class="btn">Close</a>
      </div>
    </div>
  </div>
</div>
          </main>
          <div class="content-pagination">
          </div>
        </div>
        <footer class="footer">
          <div class="footer-container">
            <div class="footer-social">
              <div class="footer-link footer-logo">
                <a href="https://metacpan.org/">
                  <img src="https://metacpan.org/static/images/metacpan-logo.svg" alt="MetaCPAN" />
                </a>
              </div>
              <a class="footer-social-link" href="https://github.com/metacpan">
                <i class="fab fa-github-square"></i>
              </a>
              <a class="footer-social-link" href="https://fosstodon.org/@metacpan">
                <i class="fab fa-mastodon"></i>
              </a>
            </div>
            <div class="footer-links">
              <div class="footer-link">
                  <a href="https://metacpan.org/about">About</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/sponsors">Sponsor</a>
              </div>
              <div class="footer-link">
                  <a href="https://grep.metacpan.org">grep::cpan</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/recent">Recent</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/about/faq">FAQ</a>
              </div>
              <div class="footer-link">
                  <a href="https://metacpan.org/tools">Tools</a>
              </div>
              <div class="footer-link">
                  <a href="https://fastapi.metacpan.org/">API</a>
              </div>
              <div class="footer-link">
                  <a href="https://www.perl.org/">Perl.org</a>
              </div>
            </div>
            <div class="footer-sponsors">
              <a class="footer-sponsor-link" target="_blank" href="https://www.bytemark.co.uk/" rel="noopener">
                <img class="footer-sponsor-bytemark" src="https://metacpan.org/static/images/sponsors/bytemark_logo.svg" alt="Bytemark logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.liquidweb.com/" rel="noopener">
                <img class="footer-sponsor-liquidweb" src="https://metacpan.org/static/images/sponsors/liquidweb_logo.png" alt="liquidweb logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://deriv.com/careers/" rel="noopener">
                <img class="footer-sponsor-deriv" src="https://metacpan.org/static/images/sponsors/deriv.svg" alt="Deriv logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://geocode.xyz" rel="noopener">
                <img class="footer-sponsor-geocode" src="https://metacpan.org/static/images/sponsors/geocodelogo.svg" alt="Geocode logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://www.fastly.com/" rel="noopener">
                <img class="footer-sponsor-fastly" src="https://metacpan.org/static/images/sponsors/fastly_logo.svg" alt="Fastly logo">
              </a>
              <a class="footer-sponsor-link" target="_blank" href="https://opencagedata.com" rel="noopener">
                <img class="footer-sponsor-opencage" src="https://metacpan.org/static/images/sponsors/open-cage.svg" alt="OpenCage logo">
              </a>
            </div>
          </div>
        </footer>
        <div class="modal fade" tabindex="-1" role="dialog" id="metacpan_keyboard-shortcuts">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">&times;</button>
                <h4 class="modal-title">Keyboard Shortcuts</h4>
              </div>
              <div class="modal-body row">
<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Global</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>s</kbd>
        </td>
        <td>Focus search bar</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>?</kbd>
        </td>
        <td>Bring up this help dialog</td>
      </tr>
    </tbody>
  </table>

  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>GitHub</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>p</kbd>
        </td>
        <td>Go to pull requests</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>go to github issues (only if github is preferred repository)</td>
      </tr>
    </tbody>
  </table>
</div>

<div class="col-md-6">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>POD</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>a</kbd>
        </td>
        <td>Go to author</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>c</kbd>
        </td>
        <td>Go to changes</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>i</kbd>
        </td>
        <td>Go to issues</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>d</kbd>
        </td>
        <td>Go to dist</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>r</kbd>
        </td>
        <td>Go to repository/SCM</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>s</kbd>
        </td>
        <td>Go to source</td>
      </tr>
      <tr>
        <td class="keys">
          <kbd>g</kbd> <kbd>b</kbd>
        </td>
        <td>Go to file browse</td>
      </tr>

    </tbody>
  </table>
</div>

<div class="col-md-12">
  <table class="table keyboard-shortcuts">
    <thead>
      <tr>
        <th></th>
        <th>Search terms</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><em>module:</em> (e.g. <a href="https://metacpan.org/search?q=module%3APlugin">module:Plugin</a>)</td>
      </tr>
      <tr>
        <td><em>distribution:</em> (e.g. <a href="https://metacpan.org/search?q=distribution%3ADancer+auth">distribution:Dancer auth</a>)</td>
      </tr>
      <tr>
        <td><em>author:</em> (e.g. <a href="https://metacpan.org/search?q=author%3ASONGMU+Redis">author:SONGMU Redis</a>)</td>
      </tr>
      <tr>
        <td><em>version:</em> (e.g. <a href="https://metacpan.org/search?q=version%3A1.00">version:1.00</a>)</td>
      </tr>
    </tbody>
  </table>
</div>
              </div>
              <div class="modal-footer"></div>
            </div>
          </div>
        </div>
    </body>
</html>
